using UnityEngine;

public class CoinGroupAnimation
{
	public void show_coin(Transform transParent, Vector3 startPos, Vector3 targetPos, GameObject ojPrefab, bool isCoin)
	{
		GameObject gameObject = Object.Instantiate(ojPrefab) as GameObject;
		gameObject.transform.rotation = Quaternion.identity;
		gameObject.transform.parent = transParent;
		gameObject.transform.localPosition = new Vector3(startPos.x + (float)Random.Range(-15, 15), startPos.y + (float)Random.Range(-15, 15), startPos.z);
		float delay = Random.Range(0.3f, 0.5f);
		TweenScale component = gameObject.GetComponent<TweenScale>();
		component.enabled = true;
		component.method = UITweener.Method.EaseOut;
		component.from = Vector3.zero;
		component.to = Vector3.one;
		component.delay = Random.Range(0f, 0.2f);
		component.duration = 0.3f;
		component.ResetToBeginning();
		component.PlayForward();
		TweenPosition component2 = gameObject.GetComponent<TweenPosition>();
		component2.enabled = true;
		component2.from = gameObject.transform.localPosition;
		component2.to = targetPos;
		component2.duration = 0.5f;
		component2.delay = delay;
		component2.ResetToBeginning();
		component2.PlayForward();
		TweenAlpha component3 = gameObject.GetComponent<TweenAlpha>();
		component3.enabled = true;
		component3.from = 1f;
		component3.to = 0f;
		component3.duration = 0.1f;
		component3.delay = 1f;
		component3.ResetToBeginning();
		component3.PlayForward();
		component3.onFinished.Clear();
		component3.AddOnFinished(dispose);
		if (isCoin)
		{
			Instance<UICoinGroup>.instance.Invoke("playCoinSound", 0.5f);
		}
		else
		{
			Instance<UICoinGroup>.instance.Invoke("playGemSound", 0.5f);
		}
	}

	public void show_timebonus(Transform transParent, Vector3 startPos, Vector3 targetPos, GameObject ojPrefab, bool isCoin)
	{
		GameObject gameObject = Object.Instantiate(ojPrefab) as GameObject;
		gameObject.transform.rotation = Quaternion.identity;
		gameObject.transform.parent = transParent;
		gameObject.transform.localPosition = new Vector3(startPos.x + (float)Random.Range(-15, 15), startPos.y + (float)Random.Range(-15, 15), startPos.z);
		float delay = Random.Range(0.3f, 0.5f);
		TweenScale component = gameObject.GetComponent<TweenScale>();
		component.enabled = true;
		component.method = UITweener.Method.EaseOut;
		component.from = Vector3.zero;
		component.to = Vector3.one;
		component.delay = Random.Range(0f, 0.2f);
		component.duration = 0.3f;
		component.ResetToBeginning();
		component.PlayForward();
		TweenPosition component2 = gameObject.GetComponent<TweenPosition>();
		component2.enabled = true;
		component2.from = gameObject.transform.localPosition;
		component2.to = component2.from;
		component2.duration = 0.5f;
		component2.delay = delay;
		component2.ResetToBeginning();
		component2.PlayForward();
		TweenAlpha component3 = gameObject.GetComponent<TweenAlpha>();
		component3.enabled = true;
		component3.from = 1f;
		component3.to = 0f;
		component3.delay = 0.3f;
		component3.duration = 0.8f;
		component3.ResetToBeginning();
		component3.PlayForward();
		component3.onFinished.Clear();
		component3.AddOnFinished(dispose);
		if (isCoin)
		{
			Instance<UICoinGroup>.instance.Invoke("playCoinSound", 0.5f);
		}
		else
		{
			Instance<UICoinGroup>.instance.Invoke("playGemSound", 0.5f);
		}
	}

	public void dispose()
	{
		UnityEngine.Object.Destroy(UITweener.current.gameObject);
	}
}
